//
//  HMVisitorViewController.swift
//  微博
//
//  Created by 程双岐 on 16/9/20.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit

class HMVisitorViewController: UITableViewController {

    let isVisitor : Bool = HMUserAccpuntViewModel.sharedUserAccountViewModel.isLogin
    var visitor :HMVisitorView?

    
    override func loadView() {
        if isVisitor {
            super.loadView()
        }else{
            visitor = HMVisitorView()
            visitor?.visitorDelegate = self
            
            visitor?.block = { [weak self] in
                self?.pushOAuthAction()
            }
            
            view = visitor
            setupUI()
        }
    }
    
    
    func setupUI(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: #selector(loginAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: #selector(loginAction))
        
    }

    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @objc private func loginAction(){

        pushOAuthAction()
    }
    
    private func pushOAuthAction(){
        let webView = HMOAuthViewController()
        let nav = UINavigationController(rootViewController: webView)
        present(nav, animated: true, completion: nil)
        
    }

}

extension HMVisitorViewController : visitorViewDelegate
{
    func visitorViewLoginActon() {
        
    }
}

